package com.yyfax.pay.vo.order;

import com.yyfax.framework.common.Log;
import com.yyfax.framework.yyfax.enums.IdCardTypeEnum;
import com.yyfax.pay.common.enums.DataSrcEnum;
import com.yyfax.pay.common.exception.PayExceptionCode;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.validator.constraints.NotBlank;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

public class ProtocolBindSendMsgReq implements Serializable {

	protected Logger logger = LoggerFactory.getLogger(getClass());

	@NotBlank(message = "orderId不能为空")
	private String orderId;

	@NotBlank(message = "userId不能为空")
	private String userId;

	@NotBlank(message = "idNo不能为空")
	private String idNo;

	@NotBlank(message = "cardNo不能为空")
	private String cardNo;

	@NotBlank(message = "accountName不能为空")
	private String accountName;

	@NotBlank(message = "phone不能为空")
	private String phone;

	@NotNull(message = "orderTime不能为空")
	private Date orderTime;

	@NotBlank(message = "paymentCode不能为空")
	private String paymentCode;

	@NotBlank(message = "bankCode不能为空")
	private String bankCode;

	private Integer dataSrc;

	private Integer certifyType;

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getIdNo() {
		return idNo;
	}

	public void setIdNo(String idNo) {
		this.idNo = idNo;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public String getAccountName() {
		return accountName;
	}

	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public Date getOrderTime() {
		return orderTime;
	}

	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}

	public Integer getDataSrc() {
		return dataSrc;
	}

	public void setDataSrc(Integer dataSrc) {
		this.dataSrc = dataSrc;
	}

	public Integer getCertifyType() {
		return certifyType;
	}

	public void setCertifyType(Integer certifyType) {
		this.certifyType = certifyType;
	}

	public String getPaymentCode() {
		return paymentCode;
	}

	public void setPaymentCode(String paymentCode) {
		this.paymentCode = paymentCode;
	}

	public String getBankCode() {
		return bankCode;
	}

	public void setBankCode(String bankCode) {
		this.bankCode = bankCode;
	}

	public void checkValue() {
		final String OP = "ProtocolBindSendMsgReq.checkValue";
		if (null == this.getCertifyType()) {
			this.setCertifyType(Integer.valueOf(IdCardTypeEnum.PRC_ID.getValue()));
		}
		if (null == this.getDataSrc()) {
			this.setDataSrc(DataSrcEnum.BUSINESS.getValue());
		}
		if (this.getCertifyType() != Integer.valueOf(IdCardTypeEnum.PRC_ID.getValue())) {
			logger.error(Log.op(OP).msg("certifyType参数异常").kv("certifyType", this.getCertifyType()).toString());
			throw PayExceptionCode.ERROR_ILL_PARAMETER.exp();
		}
		if (this.getDataSrc() != DataSrcEnum.BUSINESS.getValue()) {
			logger.error(Log.op(OP).msg("dataSrc参数异常").kv("dataSrc", this.getDataSrc()).toString());
			throw PayExceptionCode.ERROR_ILL_PARAMETER.exp();
		}
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}
}
